using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace WeberTimeTracker.Models.Mapping
{
    public class Users_On_ProjectsMap : EntityTypeConfiguration<Users_On_Projects>
    {
        public Users_On_ProjectsMap()
        {
            // Primary Key
            this.HasKey(t => t.User_On_Project_ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("Users_On_Projects");
            this.Property(t => t.User_On_Project_ID).HasColumnName("User_On_Project_ID");
            this.Property(t => t.User_ID).HasColumnName("User_ID");
            this.Property(t => t.Project_ID).HasColumnName("Project_ID");

            // Relationships
            this.HasRequired(t => t.Project)
                .WithMany(t => t.Users_On_Projects)
                .HasForeignKey(d => d.Project_ID);
            this.HasRequired(t => t.User)
                .WithMany(t => t.Users_On_Projects)
                .HasForeignKey(d => d.User_ID);

        }
    }
}
